<?php


namespace app\applet\middleware;


use app\utils\JwtUtils;

class CheckLogin
{
    public function handle($request, \Closure $next)
    {
        //echo '123';
        $accessToken=request()->header("accessToken");
        if(empty($accessToken)){
            return json(["code"=>403,'msg' => "用户未登录"]);
        }
        $request->accessToken=  $accessToken;
        $userResult=JwtUtils::getDecodeToken($accessToken);
        $request->openid=  $userResult["userid"];
        return $next($request);  //返回request闭包 固定格式写到这里
    }
}